#ifndef _DSWALARMCENTER_H
#define _DSWALARMCENTER_H

#include "base.h"

class CDswalarmcenter
{
public:
	CDswalarmcenter(LPST_ENV_T pEnv);
	virtual ~CDswalarmcenter();
private:
	static void cbTimerTask(int fd, short events, void* ctx){((CDswalarmcenter*)ctx)->OnTimer(fd, events);};
	void OnTimer(int fd, short events);

	static void* cbAlarmProcessThread(void* pParam){((CDswalarmcenter*)pParam)->AlarmProcessThread();return NULL;};
	void AlarmProcessThread();
	LPST_ALARM_MSG_T CloneAlarmMsg(LPST_ALARM_MSG_T pSrc);
	static void cbDealAlarm(void* pAlarm, void* pCaller){((CDswalarmcenter*)pCaller)->DealAlarm(pAlarm);};
	void DealAlarm(void* pAlarm);

public:
	bool CreateAlarmNode(unsigned int nAreId, unsigned int nTrigValue, void* pParam, int nParamSize);
private:
#if 0
	void CheckPower();
	void CheckOnOffLine();
#endif
	void CheckDiskSpace();

	void OnProcessAction(void* pAlarm);
	
	void OnAcDc(void* pAlarm);
	void OnOffLine(void* pAlarm);
	void OnLPower(void* pAlarm);
	void OnAreAlarm(void* pAlarm);
private:
	LPST_ENV_T m_pEnv;
	timer_param_t m_nTimer;

	ST_LIST_ALARM_MSG_T m_alarm_msg, m_process_msg;
	int m_n100ms, m_n60S;

	pthread_t m_thread_id;

	EN_POWER_TYPE m_nOldPwrStatus;
	bool m_bOldLinkStatus, m_bOldLowPower;

	time_t m_nLockTime;
};

#endif

